import { Redirect } from 'umi'

function useAuth() {
    let isLogin = sessionStorage.getItem('token')? true: false
    return {
        isLogin
    }
}

export default (props: any) => {
    // hooks
    const { isLogin } = useAuth();
    if (isLogin) {
        return <div>{props.children}</div>;
    } else {
        return <Redirect to="/login" />;
    }
}